package com.ideaaedi.springcloud.jd.user.controller.sys;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.ideaaedi.springcloud.jd.commonds.entity.PageInfo;
import com.ideaaedi.springcloud.jd.commonds.entity.Result;
import com.ideaaedi.springcloud.jd.commonds.entity.user.vo.req.SysTenantListReqVO;
import com.ideaaedi.springcloud.jd.commonds.entity.user.vo.resp.SysTenantDetailRespVO;
import com.ideaaedi.springcloud.jd.commonds.entity.user.vo.resp.SysTenantListRespVO;
import com.ideaaedi.springcloud.jd.user.service.SysTenantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 系统-业务租户
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 2021.0.5.B
 */
@Validated
@RestController
@ApiSort(value = 12)
@RequestMapping("/sys-tenant")
@Api(value = "系统-业务租户", tags = {"系统-业务租户"})
public class SysTenantController {

    @Resource
    private SysTenantService sysTenantService;

    /**
     * 查列表
     *
     * @param req 参数
     *
     * @return 数据列表
     */
    @PostMapping("/list")
    @ApiOperation(value = "查列表")
    @ApiOperationSupport(order = 1)
    public Result<PageInfo<SysTenantListRespVO>> list(@RequestBody @Validated SysTenantListReqVO req) {
        return Result.success(sysTenantService.list(req));
    }
    
    /**
     * 查详情
     *
     * @param id 要查询数据的id
     *
     * @return 数据详情
     */
    @ApiOperation(value = "查详情")
    @GetMapping("/detail/{id}")
    @ApiOperationSupport(order = 2)
    public Result<SysTenantDetailRespVO> detail(@ApiParam(value = "要查询数据的id", required = true)
                                            @PathVariable("id") @NotNull(message = "id cannot be null.") Long id) {
        return Result.success(sysTenantService.detail(id));
    }
}
